package com.zbkj.crmeb.store.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.common.PageParamRequest;
import com.github.pagehelper.PageInfo;
import com.zbkj.crmeb.enums.AccountFlowTypeEnum;
import com.zbkj.crmeb.front.response.ProductDetailResponse;
import com.zbkj.crmeb.front.response.ProductResponse;
import com.zbkj.crmeb.store.model.StoreOrder;
import com.zbkj.crmeb.store.model.StoreOrderInfo;
import com.zbkj.crmeb.store.model.StoreProduct;
import com.zbkj.crmeb.store.model.UserCommission;
import com.zbkj.crmeb.store.request.RetailShopStairUserRequest;
import com.zbkj.crmeb.store.request.UserCommissionRequest;
import com.zbkj.crmeb.store.response.RetailShopTopResponse;
import com.zbkj.crmeb.store.response.RetailShopUserOrderResponse;

import java.math.BigDecimal;
import java.util.List;


/**
* @author Mr.Zhang
* @description UserCommissionService 接口
* @date 2020-05-28
*/
public interface UserCommissionService extends IService<UserCommission> {

    /**
     * 下单成功 冻结佣金
     * @author cyz
     * @date 2021/5/12 11:24
     * @param storeOrder
     * @return null
     */
    public void freezeUserCommission(StoreOrder storeOrder,List<StoreOrderInfo> storeOrderInfoList, boolean leaderResult);

    /**
     * 下单成功 团长佣金
     * @author cyz
     * @date 2021/5/12 11:24
     * @param storeOrder
     * @return null
     */
    public boolean freezeUserCommissionV2(StoreOrder storeOrder,List<StoreOrderInfo> storeOrderInfoList);

    void userCommissionCancel(StoreOrderInfo orderInfo);

    /**
     * 当前商品是否应该享有优惠价
     * @param uid
     * @param merId
     */
    void setPreferentialPrice(ProductDetailResponse productDetailResponse, ProductResponse productResponse, Integer uid, Integer merId);

    void freezeUserCommissionTest(StoreOrder storeOrder,List<StoreOrderInfo> storeOrderInfoList);

    /**
     * 退款 更新冻结佣金
     * @author cyz
     * @date 2021/5/12 11:24
     * @param storeOrderInfo
     * @return null
     */
    public void refundCommission(StoreOrderInfo storeOrderInfo);

    /**
     * 定时任务 解冻佣金
     * @author cyz
     * @date 2021/5/12 11:53
     */
    public void unfreezeOrder();

    /**
     * 查询冻结解冻金额
     * @author cyz
     * @date 2021/5/12 15:10
     * @param uid 
     * @return java.math.BigDecimal
     */
    public BigDecimal selectFreezeAmount(Integer uid,Integer status);

    /**
     * 查询佣金明细
     * @author cyz
     * @date 2021/5/12 15:43
     * @param request 
     * @return java.util.List<com.zbkj.crmeb.store.model.UserCommission>
     */
    public PageInfo<UserCommission> selectUserCommissionList(UserCommissionRequest request, PageParamRequest pageParamRequest);

    void completeCommission(StoreOrderInfo storeOrderInfo);

    void saveUserCommission(Integer uid, String orderId,
                            Integer type, Integer status, Integer isFreeze,
                            BigDecimal totalAmount, BigDecimal freezeAmount, BigDecimal withdrawalAmount, BigDecimal closeAmount,BigDecimal userAmount,
                            String title,String remark);

    void saveUserCommissionV2(Integer uid, String orderId,
                         Integer type, Integer status, Integer isFreeze,
                         BigDecimal totalAmount, BigDecimal freezeAmount, BigDecimal withdrawalAmount, BigDecimal closeAmount, BigDecimal userAmount,
                         String title, String remark, Integer activityGroupId, Integer isGroupRebate, Integer orderComplete);

    PageInfo<RetailShopUserOrderResponse> getOrderListBySpreadLevel(RetailShopStairUserRequest request, PageParamRequest pageParamRequest);

    RetailShopTopResponse getPromotionOrder(List<Integer> uidList);

    void completeCommissionForGroupActivity();
}
